home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / awe2-0_1.lha / awe2-0.1 / Src / RCS / SpinBarrier.h,v < prev    next >
Text File  |  1989-02-22  |  4KB  |  256 lines

  1. head     3.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    grunwald:3.2; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 3.2
  10. date     89.02.20.15.37.32;  author grunwald;  state Exp;
  11. branches ;
  12. next     3.1;
  13.  
  14. 3.1
  15. date     88.12.20.13.50.18;  author grunwald;  state Exp;
  16. branches ;
  17. next     1.3;
  18.  
  19. 1.3
  20. date     88.10.30.13.06.05;  author grunwald;  state Exp;
  21. branches ;
  22. next     1.2;
  23.  
  24. 1.2
  25. date     88.09.28.22.13.43;  author grunwald;  state Exp;
  26. branches ;
  27. next     1.1;
  28.  
  29. 1.1
  30. date     88.09.18.16.42.07;  author grunwald;  state Exp;
  31. branches ;
  32. next     ;
  33.  
  34.  
  35. desc
  36. @@
  37.  
  38.  
  39. 3.2
  40. log
  41. @Start using Gnu library heaps for schedulers
  42. @
  43. text
  44. @// This may look like C code, but it is really -*- C++ -*-
  45. // 
  46. // Copyright (C) 1988 University of Illinois, Urbana, Illinois
  47. //
  48. // written by Dirk Grunwald (grunwald@@cs.uiuc.edu)
  49. //
  50. #ifndef SpinBarrier_h
  51. #define SpinBarrier_h
  52.  
  53. //
  54. //    Implement a UNIX process barrier
  55. //
  56.  
  57. #include "SpinLock.h"
  58. #include "Config.h"
  59. #include "assert.h"
  60.  
  61. class SpinBarrier : SpinLock {
  62.     short pHeight;
  63.     short pCount;
  64.     short generation;
  65.     short pLoops;
  66.     int pMaxLoops;
  67. public:
  68.     SpinBarrier( int h, int loops = DefaultSpinBarrierLoops, int max = 0 );
  69.     ~SpinBarrier();
  70.  
  71.     //
  72.     // Normal entry. Everyone calls rendezvous()
  73.     //
  74.     int rendezvous();
  75.     //
  76.     // lowerBarrier forces all waiting jobs to continue
  77.     //
  78.     void lowerBarrier();
  79.  
  80.     //
  81.     // Changing the height of the barrier can cause people to continue
  82.     // if it is lowered below the current pCount.
  83.     //
  84.     int height();
  85.     void height(int h);
  86.  
  87.     //
  88.     // loops() is the numbr of times a barrier spins before doing a getpid()
  89.     // to release the UNIX cpu. maxLoopss() the maximum number of getpids()
  90.     // to do before returning from the barrier (i.e. for barrier with timeout)
  91.     //
  92.     int loops();
  93.     void loops(int h);
  94.     int maxLoops();
  95.     void maxLoops(int h);
  96.  
  97.     int count();
  98. };
  99.  
  100. inline
  101. SpinBarrier::SpinBarrier( int h, int l, int m )
  102. {
  103.     pHeight = h;
  104.     pLoops = l;
  105.     pMaxLoops = m;
  106.     pCount = 0;
  107. }
  108.  
  109. inline int
  110. SpinBarrier::height()
  111. {
  112.     return(pHeight);
  113. }
  114.  
  115. inline int
  116. SpinBarrier::loops()
  117. {
  118.     return(pLoops);
  119. }
  120.  
  121. inline void
  122. SpinBarrier::loops(int h)
  123. {
  124.     pLoops = h;
  125. }
  126.  
  127. inline int
  128. SpinBarrier::maxLoops()
  129. {
  130.     return(pMaxLoops);
  131. }
  132.  
  133. inline void
  134. SpinBarrier::maxLoops(int h)
  135. {
  136.     pMaxLoops = h;
  137. }
  138.  
  139. inline int
  140. SpinBarrier::count()
  141. {
  142.     return(pCount);
  143. }
  144.  
  145. inline
  146. SpinBarrier::~SpinBarrier()
  147. {
  148.     assert( pCount == 0 );
  149. }
  150.  
  151. #endif
  152. @
  153.  
  154.  
  155. 3.1
  156. log
  157. @Steay version
  158. @
  159. text
  160. @@
  161.  
  162.  
  163. 1.3
  164. log
  165. @*** empty log message ***
  166. @
  167. text
  168. @d18 1
  169. a18 1
  170. class SpinBarrier : public SpinLock {
  171. d20 1
  172. a20 1
  173.     short count;
  174. d23 1
  175. d25 1
  176. a25 1
  177.     SpinBarrier( int h, int loops = DefaultSpinBarrierLoops );
  178. d27 14
  179. d43 12
  180. a54 1
  181.     void rendezvous();
  182. d58 1
  183. a58 1
  184. SpinBarrier::SpinBarrier( int h, int l )
  185. d62 2
  186. a63 1
  187.     count = 0;
  188. d72 6
  189. d79 1
  190. a79 1
  191. SpinBarrier::height(int h)
  192. d81 1
  193. a81 1
  194.     pHeight = h;
  195. d84 18
  196. d105 1
  197. a105 1
  198.     assert( count == 0 );
  199. @
  200.  
  201.  
  202. 1.2
  203. log
  204. @*** empty log message ***
  205. @
  206. text
  207. @d1 8
  208. a8 2
  209. #ifndef HardBarrier_h
  210. #define HardBarrier_h
  211. d14 2
  212. a15 1
  213. #include "HardSpinLock.h"
  214. d18 1
  215. a18 1
  216. class HardBarrier : public HardSpinLock {
  217. d24 2
  218. a25 2
  219.     HardBarrier( int h, int loops = 1000 );
  220.     ~HardBarrier();
  221. d32 1
  222. a32 1
  223. HardBarrier::HardBarrier( int h, int l )
  224. d40 1
  225. a40 1
  226. HardBarrier::height()
  227. d46 1
  228. a46 1
  229. HardBarrier::height(int h)
  230. d52 1
  231. a52 1
  232. HardBarrier::~HardBarrier()
  233. @
  234.  
  235.  
  236. 1.1
  237. log
  238. @Initial revision
  239. @
  240. text
  241. @d9 1
  242. d11 1
  243. a11 2
  244. class HardBarrier {
  245.     HardSpinLock lock;
  246. d15 1
  247. d17 1
  248. a17 1
  249.     HardBarrier( int h );
  250. d25 1
  251. a25 1
  252. HardBarrier::HardBarrier( int h )
  253. d28 1
  254. d47 1
  255. @
  256.